<?php

namespace app\common\model;

use think\Model;

class BgPosts extends Model
{
    //
    protected $autoWriteTimestamp=true;

    protected function base($query){
        $query->where('status',1);
    }

    public function user(){
        return $this->hasOne('Users','uid','uid');
    }

    //关联post_topic_access 表
    public function access(){
        return $this->hasOne('PostTopicAccess','post_id');
    }

    //关联topic
    public function topic()
    {
        return $this->belongsToMany('topics','post_topic_access','topic_id','post_id');
    }

    //查询不在topic中的post文章
}
